// web/src/app/learn/(dashboard)/(routes)/teacher/courses/page.tsx
import React from 'react';
import {columns} from "@/app/learn/(dashboard)/(routes)/teacher/courses/_components/columns";
import {DataTable} from "@/app/learn/(dashboard)/(routes)/teacher/courses/_components/data-table";
import {currentUser} from "@/lib/auth";
import {redirect} from "next/navigation";
import {db} from '@/lib/db'

const Page = async () => {
    const user = await currentUser()
    if (!user) return redirect('/learn')

    const course = await db.course.findMany({
        where: {userId: user.id},
        orderBy: {createdAt: 'desc'},
    })

    return (
        <div className={`p-6`}>
            <DataTable columns={columns} data={course}/>
        </div>
    );
};

export default Page;